//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "PatternRecord.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define LENGTHTEXT 1000
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
PatternRecord::PatternRecord ():paramCode(0),
                                hits(0),
                                seq(0),
                                fitness(0.0),
                                probability(0),
                                weight(0) {
  
  this->pattern  = new String ();
  this->toString = new String ();
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
PatternRecord::PatternRecord (const PatternRecord& patternRecord) {
  
  this->paramCode   = patternRecord.paramCode;
  
  this->hits        = patternRecord.hits;
  this->seq         = patternRecord.seq;
  
  this->fitness     = patternRecord.fitness;
  this->probability = patternRecord.probability;
  this->weight      = patternRecord.weight;
  
  this->pattern     = new String (patternRecord.pattern);
  this->toString    = new String ();
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
PatternRecord::PatternRecord (const PatternRecord* patternRecord) {
  
  this->paramCode   = patternRecord->paramCode;
  
  this->hits        = patternRecord->hits;
  this->seq         = patternRecord->seq;
  
  this->fitness     = patternRecord->fitness;
  this->probability = patternRecord->probability;
  this->weight      = patternRecord->weight;
  
  this->pattern     = new String (patternRecord->pattern);
  this->toString    = new String ();
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
PatternRecord::~PatternRecord () {
  
  if (this->pattern)  delete this->pattern;
  if (this->toString) delete this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::Pattern (String* pattern) {
  
  if (pattern) this->pattern->In(pattern);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::ParamCode (int paramCode) {
  
  this->paramCode = paramCode;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::Hits (int hits) {
  
  if (hits > 0) this->hits = hits;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::Seq (int seq) {
  
  if (seq > 0) this->seq = seq;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::Fitness (double fitness) {
  
  if (fitness > 0) this->fitness = fitness;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::Probability (double probability) {
  
  if (probability > 0) this->probability = probability;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void PatternRecord::Weight (double weight) {
  
  if (weight >= 0) this->weight = weight;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* PatternRecord::Pattern (void) {
  
  return this->pattern;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int PatternRecord::ParamCode (void) {
  
  return this->paramCode;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int PatternRecord::Hits (void) {
  
  return this->hits;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int PatternRecord::Seq (void) {
  
  return this->seq;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double PatternRecord::Fitness (void) {
  
  return this->fitness;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double PatternRecord::Probability (void) {
  
  return this->probability;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double PatternRecord::Weight (void) {
  
  return this->weight;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* PatternRecord::ToString (void) {
  
  char    buffer [LENGTHTEXT + 1];
  
  sprintf(buffer, "%2d %4d %4d %10lf %10lf %10lf %s\0", this->paramCode,
                                                        this->hits, 
                                                        this->seq,
                                                        this->fitness,
                                                        this->probability,
                                                        this->weight,
                                                        this->pattern->Out());
  
  this->toString->In(buffer);
  
  return this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
PatternRecord PatternRecord::operator= (const PatternRecord& patternRecord) {
  
  this->paramCode   = patternRecord.paramCode;
  
  this->hits        = patternRecord.hits;
  this->seq         = patternRecord.seq;
  
  this->fitness     = patternRecord.fitness;
  this->probability = patternRecord.probability;
  this->weight      = patternRecord.weight;
  
  this->pattern->In(patternRecord.pattern);
    
  return *this;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
